package com.yhsimon.demo;

//代理对象
public class UserServiceProxy implements UserService{
    private UserService userService;

    public UserServiceProxy(){}

    public UserServiceProxy(UserService userService) {
        this.userService = userService;
    }

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @Override
    public void add() {
        log("add");
        userService.add();
    }

    @Override
    public void update() {
        log("update");
        userService.update();
    }

    @Override
    public void delete() {
        log("delete");
        userService.delete();
    }

    @Override
    public void query() {
        log("query");
        userService.query();
    }

    //日志
    public void log(String msg){
        System.out.println("[Debug] 使用了 "+msg+"方法");
    }
}
